package com.example.pilipili.dao;

import com.example.pilipili.common.R;
import com.example.pilipili.pojo.dto.VInfo;
import com.example.pilipili.pojo.entity.Video;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author liyv
 * @since 2023-12-01
 */
@Mapper
public interface VideoMapper extends BaseMapper<Video> {

    @Select("select v.* ,t.name as tagName from video v" +
            "           join tag t on t.id = v.tid" +
            "           where v.id=#{vid}")
    VInfo selectInfoById(@Param("vid") int vid) ;

    @Select("select * from video v" +
            "    where id in (" +
            "        select l.vid from love l where l.uid = #{uid}" +
            "        )" +
            "   and v.status =2")
    List<Video> selectInfosByULove(@Param("uid") int uid) ;

    @Select("select * from video v" +
            "    where id in (" +
            "        select c.vid from collection c where c.uid = #{uid}" +
            "        )" +
            "   and v.status = 2")
    List<Video> selectInfosByUCollection(@Param("uid") int uid) ;

    @Select("select v.* ,t.name as tagName from video v" +
            "           join tag t on t.id = v.tid" +
            "           where v.status=1 ")
    List<VInfo> selectInfos() ;
}
